feat: add query collection and streaming PHP execution#22
Open
ILDaviz wants to merge 5 commits into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR enhances the TweakPHP Client PHAR runtime by adding database query instrumentation (Laravel + Symfony/Doctrine) and introducing a streaming execution mode that emits structured lifecycle/output/error events during PHP execution.
Changes:
- Add
QueryCollector+ framework-specific query providers and attach them in Laravel/Symfony loaders. - Add
execute-streamcommand and streaming execution plumbing (includingStreamingOutputand new event protocol). - Expand CI/tooling and add PHPUnit coverage for loaders, query collection, streaming behavior, and CLI error handling.
Reviewed changes
Copilot reviewed 27 out of 30 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/TinkerTest.php | Adds unit tests covering non-stream and streaming execution semantics (statements, output, errors, exit codes). |
| tests/QueryCollectorTest.php | Adds tests for Laravel and Symfony/Doctrine query collection plus instrumentation error reporting. |
| tests/OutputModifierTest.php | Adds tests ensuring output modifier preserves marker text and normalizes indentation. |
| tests/LoaderTest.php | Adds tests for loader detection/boot across Laravel, Symfony, WordPress, Pimcore, Composer, and plain PHP. |
| tests/CliTest.php | Adds tests for CLI argument parsing and runtime error reporting for execute. |
| src/Tinker.php | Implements per-statement parsing/execution, query collection, and a new streaming execution API. |
| src/OutputModifiers/CustomOutputModifier.php | Simplifies output modification (removes end-marker truncation; keeps indentation normalization). |
| src/Output/StreamingOutput.php | Introduces an Output implementation that streams chunks to a callback while filtering PsySH newline markers. |
| src/Loaders/WordPressLoader.php | Minor cleanup in version() exception handling. |
| src/Loaders/SymfonyLoader.php | Improves kernel-class discovery and registers Symfony/Doctrine query provider via the container. |
| src/Loaders/PlainPhpLoader.php | Stops changing CWD in constructor; executes within project directory and restores working directory. |
| src/Loaders/LoaderInterface.php | Updates streaming execution signature to accept an event callback. |
| src/Loaders/LaravelLoader.php | Registers Laravel query provider during loader construction. |
| src/Loaders/ComposerLoader.php | Avoids re-loading a project’s Composer autoloader if it appears already loaded. |
| src/Loaders/BaseLoader.php | Passes the streaming event callback through to Tinker. |
| src/Database/SymfonyDoctrineQueryProvider.php | Adds Symfony/Doctrine query provider supporting multiple Doctrine query-logging strategies. |
| src/Database/QueryProviderInterface.php | Defines provider contract for starting/stopping query collection. |
| src/Database/QueryCollector.php | Adds provider orchestration, query aggregation, and de-duplicated instrumentation error recording. |
| src/Database/LaravelQueryProvider.php | Adds Laravel DB::listen-based query collection gated by start/stop state. |
| README.md | Documents commands, streaming protocol, supported projects, build process, and error/result formats. |
| Makefile | Adds a reproducible PHAR build target that installs prod deps and compiles with a pinned Box version. |
| LICENSE.md | Removes the repository license file. |
| index.php | Refactors CLI: adds execute-stream, strict command validation, safer base64 decoding, structured error handling, and streaming event output. |
| composer.lock | Updates locked dependencies (including psy/psysh + php-parser) and adds dev dependencies (phpunit, pint). |
| composer.json | Adds package metadata, pins dependency constraints, and adds dev tooling + test script/autoload-dev. |
| box.json | Removes Box configuration file. |
| .gitignore | Tidies ignores and adds phpunit cache and e2e output ignores. |
| .github/workflows/tests.yml | Adds a PHP matrix CI workflow running PHPUnit. |
| .github/workflows/release.yml | Updates release pipeline to build PHARs via Makefile and upload via softprops/action-gh-release. |
| .github/workflows/code-style.yml | Runs Pint from vendor/bin and executes tests in the code-style workflow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Testing
vendor/bin/phpunit